package com.huang.springcloud;

import com.netflix.hystrix.contrib.metrics.eventstream.HystrixMetricsStreamServlet;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.context.annotation.Bean;

@SpringBootApplication
@EnableEurekaClient
@EnableCircuitBreaker //添加熔断支持
public class DeptProviderHystrix {
    public static void main(String[] args) {
        SpringApplication.run(DeptProviderHystrix.class, args);
    }

    //通用配置增加一个servlet，如果想使用hystrix dashboard来监控服务端的流量，需要配置该bean
    @Bean
    public ServletRegistrationBean hystrixMetricsStreamServlet(){
        ServletRegistrationBean<HystrixMetricsStreamServlet> registerBean = new ServletRegistrationBean<>(new HystrixMetricsStreamServlet());
        registerBean.addUrlMappings("/actuator/hystrix.stream");
        return registerBean;
    }
}
